using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq.Expressions;

namespace Charisma.MongoDb.Linq.Expressions
{
  internal sealed class CollectionExpression : MongoExpression
  {
    public string Name { get; private set; }
    public Type ElementType { get; private set; }
    public ParameterExpression Element { get; private set; }

    public CollectionExpression(string name, Type elementType, ParameterExpression element)
      : base(MongoExpressionType.Collection, typeof(IEnumerable<>).MakeGenericType(elementType))
    {
      Contract.Requires(!String.IsNullOrEmpty(name));
      Contract.Requires(elementType != null);
      Contract.Requires(element != null);
      Contract.Requires(elementType == element.Type);

      Name = name;
      ElementType = elementType;
      Element = element;
    }
  }
}